//
//  TJUser.swift
//  TJSinaWeibo
//
//  Created by 唐后能 on 16/4/14.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class TJUser: NSObject {
    
    // 用户UID
    var id:Int64 = 0
    
    // 用户昵称
    var screen_name:String?
    
    // 用户头像地址（中图），50×50像素
    var profile_image_url:String?
    
    // 用户创建（注册）时间
    var created_at:String?
    
    // verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_level: Int = -1 {
    
        didSet {
        
            switch verified_level {

                case 0: verifiedImage = UIImage(named: "avatar_vip")
                case 2,3,5: verifiedImage = UIImage(named: "avatar_enterprise_vip")
                case 220: verifiedImage = UIImage(named: "avatar_grassroot")
                default: verifiedImage = nil
            }
        }
    }
    
    // 认证图片-->供外界直接使用.
    var verifiedImage:UIImage?
    
    // 会员等级: 1-6级
    var mbrank: Int = 0 {
    
        didSet {
        
            if mbrank > 0 && mbrank<=6 {
                mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            }else {
            
                mbrankImage = nil
            }
        }
    }
    
    // 会员图片-->供外界直接使用.
    var mbrankImage:UIImage?
    
    
    // KVC构造器,进行字典转模型.
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    // 打印User的属性.
    override var description:String {
    
        get {
        
            let keys = ["id","screen_name","profile_image_url","created_at","verified_level","mbrank"]
            return "用户模型:\(dictionaryWithValuesForKeys(keys).description)"
        }
    }
}
